<h1>Templates</h1>

<h3>Editing Template: <span class='highlight'><?php echo  h($template_name) ?></span></h3>

<div id='tabsmenu'>
    <ul id='tabs'>
        <li><a href="#tab1">Template Code</a></li>
        <li><a href="#tab2">Template Functions</a></li>
    </ul>
</div>

<div id='tab1' class='tab-page'>
<?php
    if ($is_writable) {
?>   
     <?php echo form_tag('templates') ?>
     <?php echo hidden_field_tag('action','edit_template') ?>
     <?php echo hidden_field_tag('template_name',h($template_name)) ?>
     <p><?php echo text_area_tag('template_code',
                               $template_code,
                               array('size'=>'50x20',
                                     'style'=>'width:98%',
                                     'id'=>'template_code',
                                     'class'=>'codepress')) ?></p>
                                     
     <p><?php echo submit_tag('Save Template') ?>
     <?php echo submit_tag('Save and Finished') ?></p>
     <?php echo end_form_tag(); ?> 
     <?php echo javascript_tag("/js/codepress/codepress.js") ?>
                                   
<?php
    } else {
?>        
        <p class='form_error'>You will not be able to save changes to this template until it is writable by the server.</p>
        <p>To make this template editable by this interface, change permissions on this file:<b>/pixel/app/views/admin/pages/templates/<?php echo h($template_name) ?></b></p>
        <?php echo text_area_tag('template_code',
                                   $template_code,
                                   array('size'=>'50x20',
                                         'style'=>'width:98%',                                         
                                         'id'=>'template_code')) ?>
<?php        
    }
?>
</div>

<div id='tab2' class='tab-page'>
<h2>Template Code Hints</h2>

        <h3>Creating New Templates</h3>
        <p>If you need to create new templates, you will need to have ftp access and will have to upload your new template into the /pixel/app/views/admin/pages/templates/ directory.</p>
        
        <h3>Naming your templates</h3>
        <p>When creating a new template, make sure you insert the following at the top of your file so that the system will pick up the name of your template</p>
            <code>
                /*<br>
                Template Name: Human Name of your template<br>
                */
            </code>
            
        <h3>Creating snippets:</h3>
        <p> If you need to create a template that will need to be included in your other templates, prefix the file name with an underscore. It will not be listed under the Pages template drop down menus for selecting templates. You can then include this template in your template with the following syntax:</p>
            <code>
                &lt;?php include load_page_template('name_of_template.php'); ?&gt;
            </code>

            
        <h3>Editable Regions</h3>
        <p> You can create different kids of editable regions in your templates. The function arguments are as follows.</p>
            <code>create_region(page id, name of content section, section type, admin edit on)</code>
            
            <p>By default, you should only have to change the 2nd and 3rd argument. The 2nd argument, name of content section, is arbitrary and up to the template creator. The 3rd argument only accepts html, text, or textarea.</p>
            
            <code>
                <p>This is a standard WYSIWYG field<br>
                &lt;?php create_region($page-&gt;get("id"),"main_content","html",$admin_edit);?&gt;</p>

                <p>This is for a plain text field<br>
                &lt;?php create_region($page-&gt;get("id"),"another_section","text",$admin_edit);?&gt;</p>

                <p>This is for a plain textarea<br>
                &lt;?php create_region($page-&gt;get("id"),"third_section","textarea",$admin_edit);?&gt;</p>
            </code>

        <h3>Custom Fields</h3>
        <p> To access any custom field</p>
            <code>
            &lt;?php<br>
            <p>$myfield = $pages-&gt;custom_field(&apos;my field&apos;);<br>
            echo $myfield-&gt;value();</p>
            // OR if its a date field<br>
            <p>echo $myfield-&gt;date(); // formatted with http://php.net/strftime %D by default</p>
            // OR you own specific formatting<br>
            <p>echo $myfield-&gt;date(&quot;%m&quot;);</p>
            ?&gt;
            </code>
</div>